<script setup>
import {ref} from "vue";
import {logout,Test} from '../api/login.js'
import {useRouter} from "vue-router";
import useAuthStore from "@/stores/auth.js";
const authStore = useAuthStore();
const router = useRouter()
const response = ref(null);
 async function Logout() {
  try{
    console.log('开始登出');
    const res = await logout();
    response.value = res.data;
    if (response.value.code === 200){
      router.push('/login');
      authStore.logoutSuccess();
    }
  }catch(err){
    console.log(err)
  }
}

async function Test401() {
   try {
     const res = await Test();
     console.log(res);
   }catch(err){
     console.log(err)
   }
}
</script>

<template>
<button @click="Logout"> 退出登录</button>
  <button @click="Test401">401测试</button>
</template>
<style scoped>

</style>